# @Author：silence
# @Email：792245022@qq.com
# @Date：2025/3/2 19:06

import urllib.request
import urllib.parse

# 需求：获取 https://www.baidu.com/s?wd=周杰伦
# 1.urllib.parse.quote()：对字符串进行编码
# 1.urllib.parse.unquote()：对字符串进行解码
url = f"https://www.baidu.com/s?wd={urllib.parse.quote("周杰伦")}"

headers = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36"
}

request = urllib.request.Request(url=url, headers=headers)

response = urllib.request.urlopen(request)
content = response.read().decode("utf-8")
print(content)
